package com.wxyzz.canteenadmin.order.afterSales.controller;

import com.github.pagehelper.PageInfo;
import com.wxyzz.canteenadmin.order.afterSales.param.AfterSaleParam;
import com.wxyzz.canteenadmin.order.afterSales.service.AfterSalesService;
import com.wxyzz.canteenadmin.order.afterSales.vo.AfterSalesVo;
import com.wxyzz.canteenadmin.order.afterSales.vo.MemberInfoVo;
import com.wxyzz.canteencommon.common.R;
import com.wxyzz.canteencommon.entity.ordermanager.AfterSale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order/afterSales")
public class AfterSalesController {

    @Autowired
    private AfterSalesService afterSalesService;

    // 分页查询
    @GetMapping("/getAfterSale")
    public R getAfterSale(AfterSaleParam afterSaleParam) {
        PageInfo<AfterSalesVo> afterSalesPageHelper = afterSalesService.getAfterSalesPageHelper(afterSaleParam);
        return R.ok(afterSalesPageHelper);
    }

    @PostMapping("/updateAfterSale")
    public R updateAfterSale (@RequestBody AfterSale afterSale) {
        afterSalesService.updateAfterSale(afterSale);
        return R.ok();
    }

    // 通过订单号查询会员信息
    @GetMapping("/getMemberInfo")
    public R getMemberInfo(String orderNumber) {
        MemberInfoVo memberInfo = afterSalesService.getMemberInfo(orderNumber);
        return R.ok(memberInfo);
    }
}
